<?php

/**
*@作者:MissZhang
*@邮箱:<787727147@qq.com>
*@创建时间:2021/8/16 上午9:16
*@说明:代理会员模型
*/
namespace app\common\model;


use think\Model;

class DlUser extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    public function getPkAttr() {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function getLevelTextAttr($value,$data) {
        $types = [1=>'省级代理',2=>'市级代理',3=>'县级代理'];
        return $types[$data['level']];
    }
    public function getAllAddressAttr($value,$data) {
        return $data['province'].$data['city'].$data['district'].$data['address'];
    }
    public function getTimeAttr($value,$data) {
        return $data['add_time'];
    }
}